package work20240725;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public class function3 {
    public static void main(String[] args) {
        printString("dasdsawqeqw",2);
    }
    public static void printString(String s,int gard){
        Map<Character,Long> m = s.chars().mapToObj(c -> (char)c)
                .collect(Collectors.groupingBy(Function.identity(),Collectors.counting()));
        m.entrySet().stream()
                .filter(p -> p.getValue() == gard)
                .map(Map.Entry::getKey)
                .forEach(System.out::println);
    }
}
